package com.quanshu.exchange.support.api;

import com.quanshu.change.entity.BackGroundEntity;
import com.quanshu.change.person.entity.AliPayEntity;
import com.quanshu.change.person.entity.GoldListBean;
import com.quanshu.change.person.entity.GoldListEntity;
import com.quanshu.change.person.entity.NjfListEntity;
import com.quanshu.change.person.entity.SeckillGoodsBuyDetailEntity;
import com.quanshu.change.person.entity.SeckillGoodsBuyEntity;
import com.quanshu.change.person.entity.SeckillGoodsGetDetialEntity;
import com.quanshu.change.person.entity.SeckillGoodsSellDetailEntity;
import com.quanshu.change.person.entity.WxPayEntity;
import com.quanshu.exchange.support.entity.AccountBalanceEntity;
import com.quanshu.exchange.support.entity.AddressEntity;
import com.quanshu.exchange.support.entity.CattleIntegralEntity;
import com.quanshu.exchange.support.entity.ConnectionServiceEntity;
import com.quanshu.exchange.support.entity.FavoriteEntity;
import com.quanshu.exchange.support.entity.GoodsEntity;
import com.quanshu.exchange.support.entity.MemberBindEntity;
import com.quanshu.exchange.support.entity.MemberOrderEntity;
import com.quanshu.exchange.support.entity.MyOrderEntity;
import com.quanshu.exchange.support.entity.OrderDetailsEntity;
import com.quanshu.exchange.support.entity.ShoppingCarEntity;
import com.quanshu.exchange.support.entity.SystemMessageEntity;
import com.quanshu.exchange.support.net.BaseResponse;

import java.util.List;

import io.reactivex.Observable;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;

/**
 * 商品模块的接口
 * Created by xiniu003 on 2018/1/5.
 */

public interface ShopInterface {

    /**
     * 账户余额
     *
     * @return
     */
    @FormUrlEncoded
    @POST("index.php?model=api&controller=api_ucenter&action=getUser")
    Observable<BaseResponse<AccountBalanceEntity>> getBalance(@Field("user_id") String apiKey);

    /**
     * 牛积分 or GP 交易记录
     *
     * @param user_id
     * @return
     */
    @FormUrlEncoded
    @POST("index.php?model=api&controller=api_ucenter&action=transRecord")
    Observable<BaseResponse<List<CattleIntegralEntity>>> getTransRecord(@Field("apikey") String apiKey,
                                                                        @Field("user_id") String user_id,
                                                                        @Field("type") String type);
//
//    /**
//     * 我的订单
//     *
//     * @param user_id
//     * @return
//     */
//    @FormUrlEncoded
//    @POST("index.php?controller=api_ucenter&action=orderList")
//    Observable<BaseResponse<List<MyOrderEntity>>> getOrderList(@Field("apikey") String apiKey,
//                                                               @Field("user_id") String user_id);

    /**
     * 我的订单列表
     * 1.全部  2.待付款  3.待发货  4.已发货  5.已完成
     *
     * @param user_id/api_ucenter/orderInfoList
     * @return
     */
    @FormUrlEncoded
    @POST("index.php?model=api&controller=api_ucenter&action=orderInfoList")
    Observable<BaseResponse<List<MyOrderEntity>>> getOrderList(@Field("apikey") String apiKey,
                                                               @Field("user_id") String user_id,
                                                               @Field("order_type") int order_type);

    /**
     * 操作订单状态和删除 - 取消
     *
     * @param order_id  ​订单id
     * @param operaType ​操作类型(cancel / confirm / delete)  cancel
     * @return
     */
    @FormUrlEncoded
    @POST("index.php?model=api&controller=api_ucenter&action=updateOrderStatu")
    Observable<BaseResponse> doCancelOrder(@Field("apikey") String apiKey,
                                           @Field("order_id") String order_id,
                                           @Field("operaType") String operaType,
                                           @Field("goods_type") String goods_type);

    /**
     * 操作订单状态和删除 - 确认
     *
     * @param order_id  ​订单id
     * @param operaType ​操作类型(cancel / confirm / delete)  confirm
     * @return
     */
    @FormUrlEncoded
    @POST("index.php?model=api&controller=api_ucenter&action=updateOrderStatu")
    Observable<BaseResponse> doConfirmOrder(@Field("apikey") String apiKey,
                                            @Field("order_id") String order_id,
                                            @Field("operaType") String operaType,
                                            @Field("goods_type") String goods_type);

    /**
     * 操作订单状态和删除 - 删除
     *
     * @param order_id  ​订单id
     * @param operaType ​操作类型(cancel / confirm / delete)  delete
     * @return
     */
    @FormUrlEncoded
    @POST("index.php?model=api&controller=api_ucenter&action=updateOrderStatu")
    Observable<BaseResponse> doDeleteOrder(@Field("apikey") String apiKey,
                                           @Field("order_id") String order_id,
                                           @Field("operaType") String operaType,
                                           @Field("goods_type") String goods_type);

    /**
     * 订单详情
     *
     * @param order_id
     * @return
     */
    @FormUrlEncoded
    @POST("index.php?model=api&controller=api_ucenter&action=orderDetail")
    Observable<BaseResponse<OrderDetailsEntity>> getOrderDetail(@Field("apikey") String apiKey,
                                                                @Field("order_id") String order_id);

    //选择套餐
    @FormUrlEncoded
    @POST("index.php?controller=api_ucenter&action=tc_add")
    Observable<BaseResponse> doActionAdd(
            @Field("order_id") String order_id,
            @Field("week") String week,
            @Field("tcid") String tcid);

    //农产品确认收货
    @FormUrlEncoded
    @POST("index.php?controller=api_ucenter&action=tc_change_status")
    Observable<BaseResponse> doTcChangeStatus(@Field("order_id") String order_id,
                                              @Field("week") String week);

    /**
     * 购物车
     *
     * @param user_id
     * @return
     */
    @FormUrlEncoded
    @POST("index.php?controller=api_ucenter&action=getMyCart")
    Observable<BaseResponse<ShoppingCarEntity>> getMyCart(@Field("apikey") String apiKey,
                                                          @Field("user_id") String user_id);

    /**
     * 购买车商品数量增加或者减少 - 增加
     *
     * @param user_id    ​用户标识
     * @param goods_id   ​商品id
     * @param goods_type ​商品类型
     * @param goods_num  ​增加或减少的数量
     * @return
     */
    @FormUrlEncoded
    @POST("index.php?controller=api_ucenter&action=increOrReduCart")
    Observable<BaseResponse> getIncreCart(@Field("apikey") String apiKey,
                                          @Field("user_id") String user_id,
                                          @Field("goods_id") String goods_id,
                                          @Field("goods_type") String goods_type,
                                          @Field("goods_num") int goods_num);

    /**
     * 购买车商品数量增加或者减少 - 减少
     *
     * @param user_id    ​用户标识
     * @param goods_id   ​商品id
     * @param goods_type ​商品类型
     * @param goods_num  ​增加或减少的数量
     * @return
     */
    @FormUrlEncoded
    @POST("index.php?controller=api_ucenter&action=increOrReduCart")
    Observable<BaseResponse> getReduCart(@Field("apikey") String apiKey,
                                         @Field("user_id") String user_id,
                                         @Field("goods_id") String goods_id,
                                         @Field("goods_type") String goods_type,
                                         @Field("goods_num") int goods_num);

    /**
     * 批量移除购物车
     *
     * @param user_id  ​用户标识
     * @param goodsArr ​商品一维数组 例如：单个商品["goods_id goods_type"]
     *                 ,多个商品["goods_id goods_type","goods_id goods_type"]
     * @return
     */
    @FormUrlEncoded
    @POST("index.php?controller=api_ucenter&action=removeCart")
    Observable<BaseResponse> doRemoveCart(@Field("apikey") String apiKey,
                                          @Field("user_id") String user_id,
                                          @Field("goodsArr") String goodsArr);

    /**
     * 我的收藏
     *
     * @param user_id
     * @return
     */
    @FormUrlEncoded
    @POST("index.php?controller=api_ucenter&action=getFavoList")
    Observable<BaseResponse<List<FavoriteEntity>>> getFavoList(@Field("apikey") String apiKey,
                                                               @Field("user_id") String user_id);

    /**
     * 删除一条收藏记录 	​收藏id
     *
     * @param favo_id
     * @param user_id
     * @return
     */
    @FormUrlEncoded
    @POST("index.php?controller=api_ucenter&action=delFavoById")
    Observable<BaseResponse> getDelFavoById(@Field("apikey") String apiKey,
                                            @Field("favo_id") String favo_id,
                                            @Field("user_id") String user_id);

    /**
     * 收货地址列表
     *
     * @param user_id
     * @return
     */
    @FormUrlEncoded
    @POST("index.php?controller=api_ucenter&action=addressList")
    Observable<BaseResponse<List<AddressEntity>>> getAddressList(@Field("apikey") String apiKey,
                                                                 @Field("user_id") String user_id);

    /**
     * 设置默认收货地址
     *
     * @param addr_id
     * @param user_id
     * @return
     */
    @FormUrlEncoded
    @POST("index.php?controller=api_ucenter&action=setDefaultAddr")
    Observable<BaseResponse> setDefaultAddr(@Field("apikey") String apiKey,
                                            @Field("addr_id") String addr_id,
                                            @Field("user_id") String user_id);

    /**
     * 删除收货地址
     *
     * @param addr_id
     * @param user_id
     * @return
     */
    @FormUrlEncoded
    @POST("index.php?controller=api_ucenter&action=delAddrByAddrId")
    Observable<BaseResponse> getDelAddrByAddrId(@Field("apikey") String apiKey,
                                                @Field("addr_id") String addr_id,
                                                @Field("user_id") String user_id);

    /**
     * 新增或修改收货地址 - 新增
     *
     * @param user_id     ​用户唯一标识
     *                    //@param addr_id     ​地址id（修改时必传，新增不穿）  @Field("addr_id") String addr_id,
     * @param accept_name ​收货人名称
     * @param mobile      ​手机号
     * @param province    ​省编码
     * @param city        ​市编码
     * @param area        区编码
     * @param address     ​详细地址
     * @param is_default  ​是否默认（0/1）
     * @return
     */
    @FormUrlEncoded
    @POST("index.php?controller=api_ucenter&action=insertOrEditAddr")
    Observable<BaseResponse> getInsertAddr(@Field("apikey") String apiKey,
                                           @Field("user_id") String user_id,
                                           @Field("accept_name") String accept_name,
                                           @Field("mobile") String mobile,
                                           @Field("province") int province,
                                           @Field("city") int city,
                                           @Field("area") int area,
                                           @Field("address") String address,
                                           @Field("is_default") int is_default);

    /**
     * 新增或修改收货地址 - 修改
     *
     * @param user_id     ​用户唯一标识
     * @param addr_id     ​地址id（修改时必传，新增不穿）
     * @param accept_name 收货人名称
     * @param mobile      ​手机号
     * @param province    ​省编码
     * @param city        ​市编码
     * @param area        ​区编码
     * @param address     ​详细地址
     * @param is_default  是否默认（0/1）
     * @return
     */
    @FormUrlEncoded
    @POST("index.php?controller=api_ucenter&action=insertOrEditAddr")
    Observable<BaseResponse> getEditAddr(@Field("apikey") String apiKey,
                                         @Field("user_id") String user_id,
                                         @Field("addr_id") String addr_id,
                                         @Field("accept_name") String accept_name,
                                         @Field("mobile") String mobile,
                                         @Field("province") int province,
                                         @Field("city") int city,
                                         @Field("area") int area,
                                         @Field("address") String address,
                                         @Field("is_default") int is_default);

    /**
     * 联系客服
     *
     * @return
     */
    @GET("index.php?model=api&controller=api_ucenter&action=serviceCenter")
    Observable<BaseResponse<ConnectionServiceEntity>> getServiceCenter();

    /**
     * 系统消息
     *
     * @param user_id
     * @return
     */
    @FormUrlEncoded
    @POST("index.php?model=api&controller=api_ucenter&action=sysMassage")
    Observable<BaseResponse<List<SystemMessageEntity>>> getSysMassage(@Field("apikey") String apiKey,
                                                                      @Field("user_id") String user_id);

    /**
     * 系统消息设为已读或删除 - 删除
     *
     * @param msg_id      ​消息id
     * @param user_id
     * @param ​operaType​ ​操作类型（delete  or edit）
     * @return
     */
    @FormUrlEncoded
    @POST("ndex.php?controller=api_ucenter&action=delOrUpdSysMsgById")
    Observable<BaseResponse> getDelSysMsgById(@Field("apikey") String apiKey,
                                              @Field("msg_id") String msg_id,
                                              @Field("user_id") String user_id,
                                              @Field("operaType") String operaType);

    /**
     * 系统消息设为已读或删除 - 已读
     *
     * @param msg_id     ​消息id
     * @param user_id
     * @param ​operaType ​操作类型（delete  or edit）
     * @return
     */
    @FormUrlEncoded
    @POST("ndex.php?controller=api_ucenter&action=delOrUpdSysMsgById")
    Observable<BaseResponse> getUpdSysMsgById(@Field("apikey") String apiKey,
                                              @Field("msg_id") String msg_id,
                                              @Field("user_id") String user_id,
                                              @Field("operaType") String operaType);

    /**
     * 获取商品
     *
     * @return
     */
    @FormUrlEncoded
    @POST("api_ucenter/get_goods_info")
    Observable<BaseResponse<GoodsEntity>> getGoodsInfo(@Field("goods_id") String goods_id);

    /**
     * 获取退款原因
     *
     * @return
     */
    @GET("index.php?model=api&controller=api_ucenter&action=getReason")
    Observable<BaseResponse<List<String>>> getRefundReason();

    /**
     * 确定退款
     *
     * @return
     */
    @FormUrlEncoded
    @POST("index.php?model=api&controller=api_ucenter&action=refund")
    Observable<BaseResponse> doRefund(@Field("order_id") String order_id,
                                      @Field("content") String content);


    /**
     * 会员订单列表
     *
     * @return
     */
    @FormUrlEncoded
    @POST("ucenter/memberList")
    Observable<BaseResponse<List<MemberOrderEntity>>> getMemberOrderList(@Field("phone") String phone,
                                                                         @Field("status") int status);

    /**
     * 会员订单列表
     *
     * @return
     */
    @FormUrlEncoded
    @POST("ucenter/bindingsList")
    Observable<BaseResponse<List<MemberBindEntity>>> getMemberBindList(@Field("phone") String phone,
                                                                       @Field("status") int status);

    /**
     * 获取金豆充值列表
     *
     * @return
     */
    @FormUrlEncoded
    @POST("index.php?model=api&controller=api_recharge&action=getIncome")
    Observable<BaseResponse<List<GoldListEntity>>> getGoldList(@Field("user_id") String memberid);


    /**
     * 获取金豆微信支付
     *
     * @return
     */
    @FormUrlEncoded
    @POST("index.php?model=api&controller=api_recharge&action=rechargeWxPay")
    Observable<BaseResponse<WxPayEntity>> getGoldWxPay(@Field("user_id") String userID, @Field("id") String Id);

    /**
     * 获取金豆支付宝支付
     *
     * @return
     */
    @FormUrlEncoded
    @POST("index.php?model=api&controller=api_recharge&action=rechargeAliPay")
    Observable<BaseResponse<AliPayEntity>> getGoldAliPay(@Field("user_id") String UserId, @Field("id") String Id);
    /**
     * 获取金豆充值列表
     *
     * @return
     */
    @FormUrlEncoded
    @POST("index.php?model=api&controller=api_recharge&action=getGold")
    Observable<BaseResponse<GoldListBean>> getGoldRechargeList(@Field("user_id") String memberid);

    /**
     * 获取好货特卖商品明细
     *
     * @return
     */
    @FormUrlEncoded
    @POST("index.php?model=api&controller=api_ucenter&action=getDetail")
    Observable<BaseResponse<List<SeckillGoodsBuyEntity>>> getHotGoods(@Field("is_inn") String isInn,
                                                                      @Field("memberid") String memberid,
                                                                      @Field("type") String type,
                                                                      @Field("is_type") String isType);

    /**
     * 获取好货特卖商品购买详情
     *
     * @return
     */
    @FormUrlEncoded
    @POST("index.php?model=api&controller=api_ucenter&action=getProducts")
    Observable<BaseResponse<SeckillGoodsBuyDetailEntity>> getHotGoodsDetail(@Field("memberid") String memberid,
                                                                            @Field("type") String type,
                                                                            @Field("goods_id") String goodsID);

    /**
     * 获取好货特卖商品提货详情
     *
     * @return
     */
    @FormUrlEncoded
    @POST("index.php?model=api&controller=api_ucenter&action=getProducts")
    Observable<BaseResponse<SeckillGoodsGetDetialEntity>> getHotGoodsGetDetail(@Field("memberid") String memberid,
                                                                               @Field("type") String type,
                                                                               @Field("goods_id") String goodsID);

    /**
     * 获取好货特卖商品寄售详情
     *
     * @return
     */
    @FormUrlEncoded
    @POST("index.php?model=api&controller=api_ucenter&action=getSecondhand")
    Observable<BaseResponse<SeckillGoodsSellDetailEntity>> getHotGoodsSellDetail(@Field("memberid") String memberid,
                                                                                 @Field("goods_id") String goodsID,
                                                                                 @Field("is_type") String isType);

    /**
     * 牛积分 or GP 交易记录
     *
     * @param user_id
     * @return
     */
    @FormUrlEncoded
    @POST("index.php?model=api&controller=api_ucenter&action=transRecord")
    Observable<BaseResponse<List<NjfListEntity>>> getNjfList(@Field("apikey") String apiKey,
                                                             @Field("user_id") String user_id,
                                                             @Field("type") String type);


    /**
     * 进行金豆分享
     *
     * @return
     */
    @FormUrlEncoded
    @POST("/index.php?model=api&controller=api_gold&action=salesShare")
    Observable<BaseResponse<String>> shareGoldBean(@Field("memberid") String memberid,
                                                   @Field("mobile") String model,
                                                   @Field("sales") String number,
                                                   @Field("payword") String pwd);

    /**
     * 进行提现操作
     *
     * @return
     */
    @FormUrlEncoded
    @POST("index.php?model=api&controller=api_gold&action=gold_withdraw")
    Observable<BaseResponse<String>> doWithdraw(@Field("user_id") String userID,
                                                @Field("amount") String amount,
                                                @Field("payee") String payee,
                                                @Field("account_number") String account_number,
                                                @Field("bank") String bank,
                                                @Field("bank_name") String bank_name,
                                                @Field("payword") String pwd);


    /**
     * 获取活动分享图片
     *
     * @param userId
     * @return
     */
    @FormUrlEncoded
    @POST("index.php?model=api&controller=api_ucenter&action=getBackground")
    Observable<BaseResponse<BackGroundEntity>> getActivityImg(@Field("apikey") String apiKey,
                                                              @Field("user_id") String userId);
}
